package edu.ncsu.csc.itrust.beans.loaders;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import edu.ncsu.csc.itrust.beans.OverrideReasonBean;

/**
 * A loader for OverrideReasonBeans.
 * 
 * Loads in information to/from beans using ResultSets and PreparedStatements. Use the superclass to enforce consistency. 
 * For details on the paradigm for a loader (and what its methods do), see {@link BeanLoader}
 */
public class OverrideReasonBeanLoader implements BeanLoader<OverrideReasonBean> {
	public OverrideReasonBeanLoader() {
	}

	/**
	 * Loads the complete list of override codes
	 */
	public List<OverrideReasonBean> loadList(ResultSet rs) throws SQLException {
		List<OverrideReasonBean> list = new ArrayList<OverrideReasonBean>();
		while (rs.next()) {
			list.add(loadSingle(rs));
		}
		return list;
	}
	
	/**
	 * Loads the list for specific medication
	 * @param rs
	 * @return
	 * @throws SQLException
	 */
	public List<OverrideReasonBean> loadListR(ResultSet rs) throws SQLException {
		List<OverrideReasonBean> list = new ArrayList<OverrideReasonBean>();
		while (rs.next()) {
			list.add(loadSingleR(rs));
		}
		return list;
	}

	/**
	 * Loads the entry for a specific medication
	 * @param rs
	 * @return
	 * @throws SQLException
	 */
	public OverrideReasonBean loadSingleR(ResultSet rs) throws SQLException {
		OverrideReasonBean orc = new OverrideReasonBean(rs.getString("OverrideCode"));
		orc.setDescription(rs.getString("OverrideComment"));
		return orc;
	}
	
	/**
	 * Loads entry for a single code entry
	 */
	public OverrideReasonBean loadSingle(ResultSet rs) throws SQLException {
		OverrideReasonBean orc = new OverrideReasonBean(rs.getString("Code"));
		orc.setDescription(rs.getString("Description"));
		return orc;
	}
	
	public PreparedStatement loadParameters(PreparedStatement ps, OverrideReasonBean bean)
			throws SQLException {
		return null;
	}

}
